<template>
  <el-breadcrumb separator-class="el-icon-arrow-right">
    <el-breadcrumb-item v-for="(v, i) in breadList" :key="i">
      <router-link :to="v.path">{{ v.meta.title }}</router-link>
    </el-breadcrumb-item>
  </el-breadcrumb>
</template>

<script>
export default {
  data() {
    return {
      breadList: [],
    };
  },
  watch: {
    // 监听路由是否发生变化
    $route(to, from) {
      // 发生变化时，修改面包屑内容，使其更新面包屑
      this.breadList = to.matched;
    },
  },
  created() {
    // 获取当前路由，将其放入面包屑中
    this.breadList = this.$route.matched;
    console.log(this.$route.matched);
    
  },
};
</script>

<style scoped>
.el-breadcrumb {
  line-height: 60px;
}
</style>